import Vue from 'vue'
import Router from 'vue-router'
import moudle2 from './moudle2.js'
import nprogress from 'nprogress'
import 'nprogress/nprogress.css'
Vue.use(Router)
const routeBase = [{
        path: '/firstPage',
        name: 'firstPage',
        component: () => import('@/components/pages/firstPage'),
        meta: {
            title: '首页'
        }
    }
]
const routeList = routeBase.concat(moudle2)

// 编程式跳转使用this.$router.push()
const router = new Router({
    routes: [{
            path: '/',
            name: 'index',
            redirect: '/mainPage'
        },
        {
            path: '/login',
            name: 'login',
            component: (resolve) => {
                require(['@/components/page_main/page_main_login.vue'], resolve)
            }
        },
        {
            path: '/mainPage',
            name: '1',
            component: (resolve) => {
                require(['@/components/pages/mainPage'], resolve)
            },
            meta: {
                title: '报表页面'
            },
            // redirect: '/firstPage',
            children: routeList
        }
    ]
    // // 定义激活路由的样式
    // linkActiveClass: 'active'
})
router.beforeEach((to, from, next) => {
    nprogress.start()
    next()
})

router.afterEach(function (to) {
    nprogress.done()
})
export default router
